# Contributor: Sean McAvoy <seanmcavoy@gmail.com>
# Maintainer: Sean McAvoy <seanmcavoy@gmail.com>
pkgname=speedtest-go
pkgver=1.1.5
pkgrel=7
pkgdesc="web page based speed test, written in go"
url="https://librespeed.org"
arch="all"
license="LGPL-3.0-only"
makedepends="go"
# !check: no check suite
# net: fetch dependencies
options="!check net"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/librespeed/speedtest-go/archive/v$pkgver.tar.gz
	speedtest-go.initd
	settings-change.patch"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -trimpath -o speedtest main.go
}

package() {
	install -Dm755 "$srcdir"/speedtest-go.initd "$pkgdir"/etc/init.d/speedtest-go
	install -Dm644 settings.toml "$pkgdir"/etc/speedtest-go/settings.toml
	install -Dm755 speedtest "$pkgdir"/usr/bin/speedtest
	install -Dm644 -t "$pkgdir"/usr/share/$pkgname/assets web/assets/*
	install -Dm644 -t "$pkgdir"/usr/share/doc/$pkgname/ ./*.md
}

sha512sums="
556d52b6e8714f6888d7428b74717db0b9faa7d713ab67d1f37c47b7ba671b0be09aa264c02fc523ce2cf2d45300112a7405d0dfbb23e8bec70431e3dc370455  speedtest-go-1.1.5.tar.gz
197efb6f98bed3a09c1c71e520265b48671c8e4dddabf3f9d7f16e8384e1ef84b800a115d5c656fb47e48d07a92cfe387f2dba5b9801fa03e720f762c6394ff7  speedtest-go.initd
5699367c3188b8b9e58caf14641bb2bb0e9604804325649930757c342bf81700c02ad0610304c710d884b58641291bc4a16a65c80f8767f33b4137b624bef35a  settings-change.patch
"
